<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/22 0022
 * Time: 下午 5:21
 */

namespace Home\Controller;


use Think\Controller;

class CommentController extends Controller
{
    public function ajaxGetPl(){
        $goodsId = I('get.goods_id');
        $model = D('Admin/Comment');
        $data = $model->search($goodsId);
        echo json_encode($data);
    }
    public function add(){
        if(IS_POST){
            $model = D('Admin/Comment');
            if($model->create(I('post.'),1)){
                if($id=$model->add())
                   $this->success(array(
                       'id'=>$id,
                       'face'=>session('face'),
                       'username'=>session('m_username'),
                       'addtime'=>date('Y-m-d H:i:s'),
                       'content'=>I('post.content'),
                       'star'=>I('post.star'),
                   ),TRUE);
            }
            $this->error($model->getError(),'',TRUE);
        }
    }
    public function reply(){
        if(IS_POST){
            $model = D('Admin/CommentReply');
            if($model->create(I('post.'),1)){
                if($model->add())
                    $this->success(array(
                        'face'=>session('face'),
                        'username'=>session('m_username'),
                        'addtime'=>date('Y-m-d H:i:s'),
                        'content'=>I('post.content')
                    ));
            }
            $this->error($model->getError());
        }
    }
}